﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using InHD.model;
using InHD.commands;
using System.Windows.Input;

namespace InHD.viewmodels
{
    class AccPayableListViewModel:WorkspaceViewModel
    {
        #region Value Property
        private List<Supplier> _supplierRowCollection;
        private int _supplierRowIndex = -1;
        public string commandExcute = string.Empty;
        private Supplier _supplier;
        #endregion

        #region Constructor
        public AccPayableListViewModel(List<Supplier> listSupplier)
        {
            _supplierRowCollection = listSupplier;
        }
        #endregion

        #region Presentation Property
        public List<Supplier> SupplierRowCollection
        {
            get
            {
                return _supplierRowCollection;
            }
            set
            {
                if (_supplierRowCollection != value)
                {
                    _supplierRowCollection = value;
                    OnPropertyChanged("supplierRowCollection");
                }
            }
        }

        public int SupplierRowIndex
        {
            get
            {
                return this._supplierRowIndex;
            }
            set
            {
                this._supplierRowIndex = value;
                OnPropertyChanged("supplierRowIndex");
            }
        }

        public Supplier SelectedSupplier
        {
            get
            {
                return this._supplier;
            }
            set
            {
                if (value != null)
                {
                    this._supplier = value;
                }
            }
        }
        #endregion

        #region Command 
        private RelayCommand _viewTransactionListCommand;
        public ICommand ViewTransactionListCommand
        {
            get
            {
                if (_viewTransactionListCommand == null)
                {
                    _viewTransactionListCommand = new RelayCommand(
                        (param) => this.ViewTransactionList(), (param) => this.CanView);
                }
                return _viewTransactionListCommand;
            }
        }

        #endregion

        #region Command Method
        void ViewTransactionList()
        {
            commandExcute = "ViewTransactionList";
            OnRequestClose();
        }

        public bool CanView { get { return this.SelectedSupplier != null ? true : false; } }
        #endregion
    }
}
